package com.pearl.sharding.erp.controller;

import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.hint.HintManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单信息表 前端控制器
 * </p>
 *
 * @author 自动代码生成
 * @since 2024-01-24
 */
@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {


    @Autowired
    JdbcTemplate jdbcTemplate;

    /**
     * 根据ID查询
     *
     * @param tenantId 租户ID
     * @param id       主键ID
     * @return 响应数据
     */
    @GetMapping("/getById")
    public Object getById(@RequestParam Long tenantId, @RequestParam Long id) {
        HintManager hintManager = HintManager.getInstance();
        hintManager.addDatabaseShardingValue("t_order","11111");
        jdbcTemplate.queryForRowSet("select * from t_order");
        return "操作成功";
    }


    @GetMapping("/list")
    public List<Object> list() {
        return null;
    }

    @GetMapping("/page")
    public Object page() {
        return "操作成功";
    }

    @GetMapping("/save")
    public Object save() {

        return "操作成功";
    }


    @GetMapping("/getByRange")
    public Object getByRange() {

        return "查询成功";
    }
}